*************************************************
**  Part II - Replication Data Tables A10-A13  ** 
*************************************************

* Use Beck et al. (1998) BTSCS STATA Utility to create Carter & Signorino (2010) cubic polynomials of time
* Available at: https://www.prio.org/Data/Stata-Tools/

btscs attackyn_sp date gid, g(allpeacemos)
gen allpeacemos2 = allpeacemos^2
gen allpeacemos3 = allpeacemos^3

btscs softyn_sp date gid, g(softpeacemos)
gen softpeacemos2 = softpeacemos^2
gen softpeacemos3 = softpeacemos^3

btscs civyn_sp date gid, g(civpeacemos)
gen civpeacemos2 = civpeacemos^2
gen civpeacemos3 = civpeacemos^3

btscs attackyn_nsp date gid, g(peacemos)
gen peacemos2 = peacemos^2
gen peacemos3 = peacemos^3

btscs softyn_nsp date gid, g(speacemos)
gen speacemos2 = speacemos^2
gen speacemos3 = speacemos^3

btscs civyn_nsp date gid, g(cpeacemos)
gen cpeacemos2 = cpeacemos^2
gen cpeacemos3 = cpeacemos^3

*** Analyses Relaxing the Locality Coding for Deployment Locations ***

** Table A10: Incidence of terrorism (1992-2006), logistic regression 

* Model 1 *
logit attackyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid2 allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 2 * 
logit attackyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid2 allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 3 *
logit softyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid2 softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 4 *
logit softyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid2 softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 5 *
logit civyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid2 civpeacemos civpeacemos2 civpeacemos3), cl(gid)

* Model 6 *
logit civyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid2 civpeacemos civpeacemos2 civpeacemos3), cl(gid)

** Table A11: Incidence of terrorism (1992-2006), logistic regression, matching sample 
 
* Model 1 *
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo if year<2007, out(attackyn_sp)

logit attackyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid2 allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

* Model 2 *
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, out(attackyn_sp)

logit attackyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid2 allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

* Model 3 *
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo if year<2007, out(softyn_sp)

logit softyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid2 softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

* Model 4 *
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, out(softyn_sp)

logit softyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid2 softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

* Model 5 *
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo if year<2007, out(civyn_sp)

logit civyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid2 civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)

* Model 6 *
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, out(civyn_sp)

logit civyn_sp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid2 civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)




*** Analyses Relaxing the Locality Coding for Terrorist Attack and Deployment Locations ***

** Table A12: Incidence of terrorism (1992-2006), logistic regression

* Model 1
logit attackyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_nsp splag_pk_presence_gid2 peacemos peacemos2 peacemos3), cl(gid)

* Model 2
logit attackyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_nsp splag_pk_presence_gid2 peacemos peacemos2 peacemos3), cl(gid)

* Model 3
logit softyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_nsp splag_pk_presence_gid2 speacemos speacemos2 speacemos3), cl(gid)

* Model 4
logit softyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_nsp splag_pk_presence_gid2 speacemos speacemos2 speacemos3), cl(gid)

* Model 5
logit civyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_nsp splag_pk_presence_gid2 cpeacemos cpeacemos2 cpeacemos3), cl(gid)

* Model 6
logit civyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_nsp splag_pk_presence_gid2 cpeacemos cpeacemos2 cpeacemos3), cl(gid)

** Table A13: Incidence of terrorism (1992-2006), logistic regression, matching sample

* Model 1 * 
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_nsp_6mo if year<2007, out(attackyn_nsp)

logit attackyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_nsp splag_pk_presence_gid2 peacemos peacemos2 peacemos3) [fweight=_weight], cl(gid)

* Model 2 *
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_nsp_6mo, out(attackyn_nsp)

logit attackyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_nsp splag_pk_presence_gid2 peacemos peacemos2 peacemos3) [fweight=_weight], cl(gid)

* Model 3 
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_nsp_6mo if year<2007, out(softyn_nsp)

logit softyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_nsp splag_pk_presence_gid2 speacemos speacemos2 speacemos3) [fweight=_weight], cl(gid)

* Model 4 
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log softyn_nsp_6mo, out(softyn_nsp)

logit softyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_nsp splag_pk_presence_gid2 speacemos speacemos2 speacemos3) [fweight=_weight], cl(gid)

* Model 5
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_nsp_6mo if year<2007, out(civyn_nsp)

logit civyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_nsp splag_pk_presence_gid2 cpeacemos cpeacemos2 cpeacemos3) [fweight=_weight], cl(gid)

* Model 6
psmatch2 pk_presence_gid2 angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log civyn_nsp_6mo, out(civyn_nsp)

logit civyn_nsp l.(est pk_duration_gid2 pk_duration_ccode2 logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_nsp splag_pk_presence_gid2 cpeacemos cpeacemos2 cpeacemos3) [fweight=_weight], cl(gid)